package cc.lj.internal.merchant.interfaces.facade;

import cc.lj.internal.core.exception.SysExceptionEnum;
import cc.lj.internal.core.http.HttpResult;
import cc.lj.internal.merchant.application.service.MerchantBrandAppService;
import cc.lj.internal.merchant.interfaces.dto.MerchantBrandDTO;
import cc.lj.internal.merchant.interfaces.dto.query.MerchantBrandOneQuery;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;
import javax.validation.constraints.DecimalMin;
import javax.validation.constraints.NotNull;
import java.util.List;

/**
 * 商户品牌接口信息
 * @author liangxifeng
 * @date 2022-07-07
 */

@RestController
@RequestMapping("/merchantBrand")
@Api(tags = "商户品牌接口信息")
@Slf4j
@Validated
public class MerchantBrandController {

    @Autowired
    private MerchantBrandAppService brandAppService;

    @GetMapping("/mountBrand")
    @ApiOperation(value = "查询某个商户已挂接品牌列表接口",notes = "")
    public HttpResult<List<MerchantBrandDTO>> getBrandByMerchantId(@NotNull @DecimalMin("1") @RequestParam(required = true) Integer merchantId)
    {
        List<MerchantBrandDTO>  merchantBrandDTOS = brandAppService.getByMerchantId(merchantId);
        return HttpResult.success(SysExceptionEnum.SUCCESS.getCode(),SysExceptionEnum.SUCCESS.getMessage(),merchantBrandDTOS);
    }

    @PostMapping("/getOne")
    @ApiOperation(value = "通过品牌主键 或 者品牌主键+商户主键，查询单条品牌数据",notes = "")
    public HttpResult<MerchantBrandDTO> getOne(@Valid @RequestBody MerchantBrandOneQuery brandOneQuery)
    {
        MerchantBrandDTO  merchantBrandDTO = brandAppService.getOne(brandOneQuery);
        return HttpResult.success(SysExceptionEnum.SUCCESS.getCode(),SysExceptionEnum.SUCCESS.getMessage(),merchantBrandDTO);
    }

}
